package run.vue.iblog.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import run.vue.iblog.entity.Book;

import java.util.List;

@Repository
public interface BookMapper extends BaseMapper<Book> {
    // 查找所有图书
    List<Book> findAll();

    // 通过分类查询
    List<Book> findAllByCategoty(int cid);

    // 通过标题或者作者关键字查找
    List<Book> findAllByTitleLikeOrAuthorLike(@Param(value = "title") String keyword1, @Param(value = "author") String keyword2);

    // 添加或更新书籍
    void updateBook(Book book);

    // 添加书籍
    void addBook(Book book);

    // 删除书籍
    void deleteById(int id);

    // 获取图书个数
    int totalBooks();

}
